class Exploitdb < Formula
  desc "The official Exploit Database"
  homepage "https://www.exploit-db.com/"
  url "https://github.com/offensive-security/exploit-database.git",
      :tag => "2018-08-10",
      :revision => "1d21694058d92b9c455bc24003810960398c5cb8"
  version "2018-08-10"
  head "https://github.com/offensive-security/exploit-database.git"

  bottle :unneeded

  def install
    inreplace "searchsploit",
              "rc_file=\"\"", "rc_file=\"#{etc}/searchsploit_rc\""

    optpath = opt_share/"exploit-database"
    inreplace ".searchsploit_rc" do |s|
      s.gsub! "\"/opt/exploit-database\"", optpath
      s.gsub! "\"/opt/exploit-database-papers\"", "#{optpath}-papers"
    end

    bin.install "searchsploit"
    etc.install ".searchsploit_rc" => "searchsploit_rc"

    upshare = share/"exploit-database"
    upshare.install %w[.git exploits files_exploits.csv files_shellcodes.csv
                       shellcodes]
  end

  test do
    system "#{bin}/searchsploit", "sendpage"
  end
end
